<%--
  Created by IntelliJ IDEA.
  User: 王长hui
  Date: 2022/10/20
  Time: 17:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link type="text/css" rel="stylesheet" href="/css/moregood.css"/>
    <link type="text/css" rel="stylesheet" href="/css/index.css"/>
    <!--引入vue得依赖必须再elementui之前引入vue-->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/qs.min.js"></script>
</head>
<body>
<div id="app">
    <el-table
            :data="tableData"
            border
            style="width: 100%">
        <el-table-column
                prop="mId"
                label="编号"
                width="100">
        </el-table-column>
        <el-table-column
                prop="mIdcard"
                label="身份证号"
                width="250">
        </el-table-column>
        <el-table-column
                prop="mTelephone"
                label="电话号码"
                width="180">
        </el-table-column>
        <el-table-column
                prop="mSex"
                label="性别"
                width="100">
        </el-table-column>
        <el-table-column
                prop="mAge"
                label="年龄"
                width="100">
        </el-table-column>
        <el-table-column
                prop="mPrice"
                label="收费"
                width="100">
        </el-table-column>
        <el-table-column
                prop="mDate"
                label="时间"
                width="180">
        </el-table-column>

        <el-table-column
                prop="condition.cCases"
                label="病因详情"
                width="180">
        </el-table-column>

        <el-table-column
                prop="condition.cSuggest"
                label="医生建议"
                width="180">
        </el-table-column>

        <el-table-column
                prop="condition.cId"
                label="病人id"
                width="180"
        v-if="false"
        >
        </el-table-column>

        <el-table-column
                fixed="right"
                label="操作"
                width="330">
            <template slot-scope="scope">
                <el-button type="success" @click="editEmp(scope.row)">修改</el-button>
            </template>
        </el-table-column>
    </el-table>

    <el-dialog
            title="提示"
            :visible.sync="dialogVisible"
            width="30%"
    >
        <!--:model:绑定表单数据-->
        <el-form  :model="updateForm" label-width="110px">

            <el-form-item label="病症" prop="newsTitle">
                <el-input v-model="updateForm.cCases"  class="ab"></el-input>
            </el-form-item>

            <el-form-item label="建议" prop="newsTitle">
                <el-input v-model="updateForm.cSuggest"  class="ab"></el-input>
            </el-form-item>

            <el-form-item label="给出建议的日期" prop="newsTitle">
                <el-date-picker
                        v-model="updateForm.cDate"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        type="datetime"
                        placeholder="选择日期时间">
                </el-date-picker>
            </el-form-item>





        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmUpdate()">确认修改</el-button>
        </span>

    </el-dialog>
</div>
</body>
<script>
    var app=new Vue({

        el: "#app",
        data:{
            dialogVisible:false,
            updateForm:{},
            tableData:[],
            cId:0,
        },
        created(){
            this.initTable();
        },
        methods:{
            //点击修改
            editEmp(row){
                console.log( )
                this.dialogVisible=true;
                row.condition.cStatus=1
                //处理时间异常


                //在此转json是为了把数据固定阻断双向绑定里面的数据同步
                let parse = JSON.parse(JSON.stringify(row.condition));
                //给出建议默认1代表已经处理

                this.updateForm = parse;
                this.cId=row.condition.cId;

            },

            //确认修改
            confirmUpdate(){
                axios.post("/condition/updateAdvise",this.updateForm).then(resp=>{
                    console.log(this.updateForm)
                    if (resp.data.code === 200){
                        this.$message.success("修改病例成功");
                        //关闭表单弹窗
                        this.dialogVisible = false;
                        //重新加载表格数据
                        this.initTable();
                    }
                })
            },

            initTable(){
                axios.post("/messagebook/selectbing").then(resp=>{
                    console.log(resp)
                    this.tableData=resp.data.data;
                    //this.cId=resp.data.data.cId;
                })
            },

        }

    })
</script>
</html>
